const form = document.querySelector('form')
const avatar = document.querySelector('.avatar')
form.addEventListener('submit', async function (e) {
  e.preventDefault()
  const fd = new FormData(this)
  console.log(fd.get('avatar'))
  const { data: res } = await axios({
    url: 'http://ajax-api.itheima.net/api/file',
    method: 'POST',
    data: fd,
  })
  console.log(res)
  const url = res.data.url
  avatar.src = url
})
